package kr.hkit.powerjava.chapter09.work;

public class BankAccount {
	private String owner;
	private int accountNumber;
	private int balance;
	private double iRate;
	
	public BankAccount() {
		
	}
	public BankAccount(String owner, int accountNumber, int balance, double iRate) {
		this.owner = owner;
		this.accountNumber = accountNumber;
		this.balance = balance;
		this.iRate =  iRate;
	}
	
	public void setBank(String owner, int accountNumber, int balance, double iRate) {
		this.owner = owner;
		this.accountNumber = accountNumber;
		this.balance = balance;
		this.iRate =  iRate;
	}
	
	public void deposit(int amount){
		balance = balance + amount;
	}
	
	public int withdraw(int amount){
		if(balance < amount || balance == 0 ){
			System.out.println("출금 불가");
			return -1;
		}else {
			balance = balance - amount;
			return amount;
		}
	
	}
	
	public void addInterest() {
		balance = (int) (balance * this.iRate);
	}
	
	@Override
	public String toString() {
		return "BankAccount [owner=" + owner + ", accountNumber="
				+ accountNumber + ", balance=" + balance + ", iRate=" + iRate
				+ "]";
	}
	

}
